package com.ruoyi.goodscart.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.goodscart.mapper.GoodsCartMapper;
import com.ruoyi.goodscart.domain.GoodsCart;
import com.ruoyi.goodscart.service.IGoodsCartService;

/**
 * 购物车Service业务层处理
 *
 * @author qingyang
 * @date 2025-03-03
 */
@Service
public class GoodsCartServiceImpl implements IGoodsCartService
{
    @Autowired
    private GoodsCartMapper goodsCartMapper;

    /**
     * 查询购物车
     *
     * @param cartId 购物车主键
     * @return 购物车
     */
    @Override
    public GoodsCart selectGoodsCartByCartId(Long cartId)
    {
        return goodsCartMapper.selectGoodsCartByCartId(cartId);
    }

    /**
     * 查询购物车列表
     *
     * @param goodsCart 购物车
     * @return 购物车
     */
    @Override
    public List<GoodsCart> selectGoodsCartList(GoodsCart goodsCart)
    {
        return goodsCartMapper.selectGoodsCartList(goodsCart);
    }

    /**
     * 新增购物车
     *
     * @param goodsCart 购物车
     * @return 结果
     */
    @Override
    public int insertGoodsCart(GoodsCart goodsCart)
    {
        goodsCart.setCreateTime(DateUtils.getNowDate());
        return goodsCartMapper.insertGoodsCart(goodsCart);
    }

    /**
     * 修改购物车
     *
     * @param goodsCart 购物车
     * @return 结果
     */
    @Override
    public int updateGoodsCart(GoodsCart goodsCart)
    {
        goodsCart.setUpdateTime(DateUtils.getNowDate());
        return goodsCartMapper.updateGoodsCart(goodsCart);
    }

    /**
     * 批量删除购物车
     *
     * @param cartIds 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteGoodsCartByCartIds(Long[] cartIds)
    {
        return goodsCartMapper.deleteGoodsCartByCartIds(cartIds);
    }

    /**
     * 删除购物车信息
     *
     * @param cartId 购物车主键
     * @return 结果
     */
    @Override
    public int deleteGoodsCartByCartId(Long cartId)
    {
        return goodsCartMapper.deleteGoodsCartByCartId(cartId);
    }
}
